/*
 * Created on 22-ago-2004
 *
 */
package gurulab.merlin.core;

import java.io.Serializable;

/**
 *
 * @author Cesar Obach-Renner, cesar AT gurulab.org
 * @version 2.0
 */
public abstract class Address implements Serializable {
    
    private String schema;
    private String domain;
    private String port;
    private String local;
    private String anchor;
    private String variable;
    
    /**
     *
     * @param schema
     * @param domain
     * @param port
     * @param local
     * @author Cesar Obach-Renner, cesar AT gurulab.org
     */
    protected Address (String schema, String domain, String port, String local){
        this.schema=schema;
        this.domain=domain;
        this.port=port;
        this.local=local;
    }
    
    /**
     *
     * @return String
     * @author Cesar Obach-Renner, cesar AT gurulab.org
     */
    public String toString (){
        StringBuffer sb=new StringBuffer ();
        
        if (schema!=null) sb.append (schema+"://");
        
        sb.append (domain);
        
        if (port!=null) sb.append (":"+port);
        if (local!=null) sb.append ("/"+local);
        if (anchor!=null) sb.append ("#"+anchor);
        if (variable!=null) sb.append ("?"+variable);
        
        return(sb.toString ());
    }
    
    /**
     *
     * @return String
     * @author Cesar Obach-Renner, cesar AT gurulab.org
     */
    public String getDomain () {
        return domain;
    }
    
    /**
     *
     * @param domain
     * @author Cesar Obach-Renner, cesar AT gurulab.org
     */
    public void setDomain (String domain) {
        this.domain = domain;
    }
    
    /**
     *
     * @return String
     * @author Cesar Obach-Renner, cesar AT gurulab.org
     */
    public String getAnchor () {
        return anchor;
    }
    
    /**
     *
     * @param anchor
     * @author Cesar Obach-Renner, cesar AT gurulab.org
     */
    public void setAnchor (String anchor) {
        this.anchor = anchor;
    }
    
    /**
     *
     * @return String
     * @author Cesar Obach-Renner, cesar AT gurulab.org
     */
    public String getLocal () {
        return local;
    }
    
    /**
     *
     * @param local
     * @author Cesar Obach-Renner, cesar AT gurulab.org
     */
    public void setLocal (String local) {
        this.local = local;
    }
    
    /**
     *
     * @return String
     * @author Cesar Obach-Renner, cesar AT gurulab.org
     */
    public String getPort () {
        return port;
    }
    
    /**
     *
     * @param port
     * @author Cesar Obach-Renner, cesar AT gurulab.org
     */
    public void setPort (String port) {
        this.port = port;
    }
    
    /**
     *
     * @return String
     * @author Cesar Obach-Renner, cesar AT gurulab.org
     */
    public String getSchema () {
        return schema;
    }
    
    /**
     *
     * @param schema
     * @author Cesar Obach-Renner, cesar AT gurulab.org
     */
    public void setSchema (String schema) {
        this.schema = schema;
    }
    
    /**
     *
     * @return String
     * @author Cesar Obach-Renner, cesar AT gurulab.org
     */
    public String getVariable () {
        return variable;
    }
    
    /**
     *
     * @param variable
     * @author Cesar Obach-Renner, cesar AT gurulab.org
     */
    public void setVariable (String variable) {
        this.variable = variable;
    }
}
